{% extends "base.html" %}

{% block extrahead %}
{# <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script> #}
{# locally modified jquery with bfcache hack #}
<script src="{{ MEDIA_URL }}/js/jquery-1.2.6.js" type="text/javascript"></script>
<script src="{{ MEDIA_URL }}/js/jquery.tablesorter.js"></script>

<script type="text/javascript">
$(function() {
    $("table.sortable").tablesorter();
    $("#toggle-disabled-uas").click(function(event) {
        $("#uas-table").toggleClass("show-enabled-uas");
        if ($("#uas-table").hasClass("show-enabled-uas")) {
            $(this).text("show disabled user agents");
        } else {
            $(this).text("hide disabled user agents");
        }
        event.preventDefault();
    });

});
</script>

<style>
#uas-table.show-enabled-uas .ua-disabled {
    display: none;
}
</style>

{% endblock %}

{% block content %}

<h2>Introduction</h2>

<p>
This project is about running test cases automatically on several versions of
the main browsers available today.
</p>

<p>
For more information about this project,
<a href="http://code.google.com/p/browsertests/">see the project page.</a>
</p>

<p><b>Warning:</b>
Due to unimplemented features and limitations, some of the tests results are
not correct.
</p>

<h2>Specifications</h2>

<p>Click on a specification below to see the list of sections, tests and results.</p>

<table class="sortable">
{# <caption>Tests per Specifications</caption> #}
<thead>
    <tr>
        <th>Spec name</th>
        <th>Section count</th>
        <th>Test count</th>
    </tr>
</thead>

<tbody>
{% for spec in specs %}
    <tr>
        <td><a href="{{ spec.get_absolute_url }}">{{ spec.label }}</a></td>
        <td>{{ spec.sum_sections }}</td>
        <td>{{ spec.sum_tests }}</td>
    </tr>
{% endfor %}
</tbody>
</table>

<h2>Tests</h2>

<p><a href="{% url test-list page=1 %}">Browse all tests</a></p>

<p><a href="{% url test-search %}">Search for tests</a></p>

<h2>Results</h2>

{# <p><a href="{% url result-list page=1 %}">Results</a><p> #}

<p><a href="{% url result-search %}">Search for results</a></p>

<p><a href="{% url result-compare-ua %}">Compare results between User Agents</a></p>

{% comment %}
{# The ua list is already available in the statistics table below #}
<h2>Useragents</h2>

<a href="{% url useragent-list page=1 %}">Useragents</a>
{% endcomment %}

<h2>Statistics:</h2>

<p>Number of tests: {{ test_count }}</p>
<p>Number of results: {{ result_count }}</p>

<table class="sortable show-enabled-uas" id="uas-table">
<caption>
    Results status per User Agent<br>
    <a href="#" id="toggle-disabled-uas">show disabled user agents</a>
</caption>
<thead>
    <tr>
        <th>label</th>
        <!--
        <th>product</th>
        <th>platform</th>
        <th>branch</th>
        <th>version</th>
         -->
        <th>platform</th>
        <th>enabled</th>
        <th># results</th>
        <th># sucess. res.</th>
        <th>success rate</th>
        <th>coverage</th>
        <th>average test duration (s)</th>
        <th>total tests duration (h)</th>
    </tr>
</thead>
<tbody>
{% for ua in uas %}
    <tr class="{% ifequal ua.enabled 0 %}ua-disabled{% endifequal %}">
        <td><a href="{{ ua.get_absolute_url}}">{{ ua }}</a></td>
        <td>{{ ua.get_platform_display }}</td>
        <td>{{ ua.enabled }}</td>
        <td>{{ ua.result__count }}</td>
        <td>{{ ua.result__succeeded__sum }}</td>
        <td>{{ ua.success_rate|floatformat }}%</td>
        <td>{{ ua.coverage|floatformat }}%</td>
        <td>{{ ua.result__duration__avg|floatformat:2 }}</td>
        <td>{{ ua.result__duration__sum|floatformat:2 }}</td>
    </tr>
{% endfor %}
</tbody>
</table>

{% endblock %}
